package top.xqf.homework.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.xqf.homework.base.BaseResult;
import top.xqf.homework.entity.TbXqfGoods;
import top.xqf.homework.service.GoodsService;

import java.util.List;

@RestController
@RequestMapping("/Goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/query")
    public BaseResult<List<TbXqfGoods>> query() throws Exception {
        return goodsService.queryAll();
    }

    @PostMapping("/add")
    public BaseResult<TbXqfGoods> add(TbXqfGoods tbXqfGoods) throws Exception{
        return goodsService.add(tbXqfGoods);
    }

    @PostMapping("/update")
    public BaseResult<TbXqfGoods> update(TbXqfGoods tbXqfGoods) throws Exception{
        return goodsService.update(tbXqfGoods);
    }

    @PostMapping("/delete")
    public BaseResult<TbXqfGoods> delete(TbXqfGoods tbXqfGoods) throws Exception{
        return goodsService.delete(tbXqfGoods);
    }
}
